<?php
$q=$_GET["q"];
$array= explode(",",$q);
$Year=$array[2];
$School_Id=$array[1];
$pro=$array[0];
$gra=$array[3];
$hint="";
include_once '../Login/databaseconnection.php';
if($Year!="Select One"&&$School_Id!=""&&$pro!="Select One"&&$pro!=""&&$gra!="Select One"&&$gra!="")
{
$tra_id=mysql_query("SELECT * FROM programme WHERE Programme_Name='$pro'");
if($row=mysql_fetch_array($tra_id))
{
$Programme_Id=$row['Programme_Id'];
}
$prog=mysql_query("SELECT * FROM programmes WHERE Programme_Id='$Programme_Id' AND Year='$Year' AND School_Id='$School_Id' AND Grade='$gra'");
if($prog)
{
if($row_prog=mysql_fetch_array($prog))
{
$Gra_Male_Students=$row_prog['No_Of_Male_Students'];
$Gra_Female_Students=$row_prog['No_Of_Female_Students'];
}
else
{
$Gra_Male_Students='0';
$Gra_Female_Students='0';
}
}
 $hint=$hint.'<table height="100" class="imgholder">
          <tr>
        <td> </td>
         <td></td>
         </tr>
         <tr>
        <th>        
        </th>
         <td>
        </td>
         </tr> 
          <tr>
        <th>        
         <label>Number of male students:</label>
         </th>
         <td>';
        $hint=$hint."<input type='text' name='Gra_Male_Students' value='$Gra_Male_Students' readonly='readonly' onmouseover='clearpopbox()'/>";
$hint=$hint.'</td>
         </tr>
         <tr>
        <th>        
         <label>Number of female students:</label>
         </th>
         <td>';
        $hint=$hint."<input type='text' name='Gra_Female_Students' value='$Gra_Female_Students' readonly='readonly' onmouseover='clearpopbox()'/>";
$hint=$hint.'</td>
         </tr>
         </table>';
}
if($hint=="")
{
if($School_Id=="")
{
$response="<font color='red'>*Please select a school!</font>";
}
$response=$response.'<table height="100" class="imgholder">
          <tr>
        <td> </td>
         <td></td>
         </tr>
         <tr>
        <th>        
        </th>
         <td>
        </td>
         </tr> 
          <tr>
        <th>        
         <label>Number of male students:</label>
         </th>
         <td>';
        $response=$response."<input type='text' name='Gra_Male_Students' readonly='readonly'/>";
$response=$response.'</td>
         </tr>
         <tr>
        <th>        
         <label>Number of female students:</label>
         </th>
         <td>';
        $response=$response."<input type='text' name='Gra_Female_Students' readonly='readonly'/>";
$response=$response.'</td>
         </tr>
         </table>';
}
else
{
$response=$hint;
}
echo $response;
?>